//
//  BarButtonView.m
//  Gunz
//
//  Created by Joggy on 16/1/21.
//  Copyright © 2016年 NUPT. All rights reserved.
//

#import "BarButtonView.h"

@implementation BarButtonView

- (instancetype)initWithFrame:(CGRect)frame name:(NSString*)title {
    self = [super initWithFrame:frame];
    self.backgroundColor = [UIColor colorWithRed:(0.992) green:(0.992) blue:(0.992) alpha:1];
    _but = [UIButton buttonWithType:UIButtonTypeSystem];
    _but.backgroundColor = BGGREEN;
    _but.layer.cornerRadius = 6;
    _butTitle = [[NSMutableAttributedString alloc] initWithString:title];
    NSRange titleRange = {0, _butTitle.length};
    [_butTitle addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:font18] range:titleRange];
    [_butTitle addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:titleRange];
    [_but setAttributedTitle:_butTitle forState:UIControlStateNormal];
    _but.frame = CGRectMake(0, 0, BBButtonWidth, BBButtonHeight);
    _but.layer.position = CGPointMake(self.frame.size.width/2, self.frame.size.height/2);
    [self addSubview:_but];
    return self;
}

- (instancetype)initWithTitle:(NSString *)title {
    self = [self initWithFrame:CGRectMake(0, [GZConst getScreenHeight] - 64 - 56, [GZConst getScreenWidth], BBViewHeight) name:title];
    return self;
}

@end
